package edu.hitsz.observer;

import edu.hitsz.aircraft.AbstractAircraft;
import edu.hitsz.basic.AbstractFlyingObject;
import edu.hitsz.bullet.BaseBullet;

import java.util.LinkedList;
import java.util.List;

public class BombObserver {
    private List<AbstractFlyingObject> bombSubscribers;

    public BombObserver() {
        bombSubscribers = new LinkedList<>();
    }

    public void subscribe(AbstractFlyingObject subscriber){
        bombSubscribers.add(subscriber);
    }

    public void subscribeAll(List<BaseBullet> subscribers){
        bombSubscribers.addAll(subscribers);
    }

    // 引爆所有非boss敌机和敌方子弹
    public void detonate(){
        bombSubscribers.forEach(subscribe -> subscribe.explode());
        bombSubscribers.clear();
    }
}
